/*
 * Copyright (c) 2009. Silenus Consultoria, S.L.
 */
package es.silenus.detecta.model;

/**
 * Survey answere validation applied to header and individual unit answers.
 *
 * @author <a href="mailto:malonso@silenus-consultoria.es">Mariano Alonso</a>
 * @since 30-jun-2009 13:39:50
 */
public enum SurveyAnswerValidation implements IntegerEnumeration {
/**
   * The invalid status.
   */
	INVALID(0, "survey.answer.invalid"), 
/**
   * The valid status.
   */
	VALID(1, "survey.answer.valid"), 
/**
   * The duplicated status.
   */
	DUPLICATED(2, "survey.answer.duplicated");
	/**
	 * The id.
	 */
	private final int id;

	/**
	 * The key.
	 */
	private final String key;

/**
   * Constructor.
   *
   * @param id  the id.
   * @param key the key.
   */
	SurveyAnswerValidation(int id, String key) {
		this.id = id;
		this.key = key;
	}

	/**
	 * Retrieves the identifier.
	 *
	 * @return the identifier.
	 */
	public int getId() {
		return id;
	}

	/**
	 * Retrieves the key.
	 *
	 * @return the key.
	 */
	public String getKey() {
		return key;
	}

	/**
	 * Retrieves a value by its identifier.
	 *
	 * @param id the id.
	 *
	 * @return the origin.
	 */
	public static SurveyAnswerValidation getById(int id) {
		switch(id) {
			case 0:
				return INVALID;

			case 1:
				return VALID;

			case 2:
				return DUPLICATED;
		}

		return null;
	}
}
